﻿using ConfExpert.Forms.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Extensions;

using DevExpress.XtraEditors.Repository;
using ConfExpert.Utility;
using DevTeamIT;

namespace ConfExpert.Forms.IT
{
    public partial class HatDevreListesi : XForm
    {
        public HatDevreListesi()
        {
            InitializeComponent();
        }

        private void HatDevreListesi_Load(object sender, EventArgs e)
        {
            gvHat.Init("GetHatDevreListesi",Session.SirketId);
            gvHat.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;

            RepositoryItemComboBox riHatTipi = new RepositoryItemComboBox();
            riHatTipi.Items.AddRange(new object[] { "Fiber İnternet","ADSL", "ADSL+2", "VDSL", "Uydu","ME Mpls VPN" });
            riHatTipi.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            gvHat.Columns["HatTipi"].ColumnEdit = riHatTipi;

            gvHat.Columns["IT_LokasyonId"].ColumnEdit = RepositoryManager.riEL;

            gvHat.MakeColumnInvisible("InsertedOn");
            gvHat.AddSummary("Fiyat");
            gvHat.SetCaptions("IT_LokasyonId:Lokasyon","Hiz:Hız(Mbps)");
            gvHat.BestFitColumns();

            this.FormClosing += HatDevreListesi_FormClosing;
            btnKaydet.ItemClick += btnKaydet_ItemClick;
        }

        void HatDevreListesi_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dr = MessageBox.Show("Değişiklikleri kaydetmemiş olabilirsiniz; çıkmak istediğinize emin misiniz?", "Uyarı", MessageBoxButtons.YesNo);

            if (dr == DialogResult.No)
                e.Cancel = true;
            else
                e.Cancel = false;
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvHat.EndEdit();
            gvHat.Update("", "IT_Hat");
            gvHat.VeriyiGuncelle("GetHatDevreListesi",Session.SirketId);
            gvHat.BestFitColumns();
        }
    }
}
